define(function(require, exports, module){

	var template = require("text!./nuui-nav.html");

	var BeforeLogonView = require("./nuui-nav-beforelogon");

	var AfterLogonView = require("./nuui-nav-afterlogon");

	/**
	 * @class Nav
	 * @memberof Nuui
	 * @classdesc 侧边栏组件,主要由CSS3实现
	 * 		App.nav即为此类
	 */
	module.exports = Marionette.LayoutView.extend({
		template:template,

		regions:{
			content:".ui-nav-content"
		},

		onRender:function(){
			var view = this;

			view.$content = view.$(".ui-nav-content");

			// 触摸遮罩层关闭侧边栏
			view.$blocker = view.$(".ui-nav-blocker").on("tap", function(){
				view.hide();
				return false;
			});

			// 初始化展示
			view.showBeforeLogon();
		},

		/**
		 * @desc 展示本侧边栏
		 * @memberof Nuui.Nav
		 * @func show
		 * @instance
		 */
		show:function(){
			this.$content.addClass("on");
			this.$blocker.addClass("on");
		},

		/**
		 * @desc 隐藏本侧边栏
		 * @memberof Nuui.Nav
		 * @func hide
		 * @instance
		 */
		hide:function(){
			this.$content.removeClass("on");
			this.$blocker.removeClass("on");
		},

		showBeforeLogon:function(){
			this.content.show(new BeforeLogonView());
		},

		showAfterLogon:function(){
			this.content.show(new AfterLogonView());
		}
	});
});
